home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / diskmags / 0022-3.564 / dmg-0085 / 293.txt < prev    next >
Text File  |  1997-04-16  |  29KB  |  667 lines

  1.  
  2. INFO-ATARI16 Digest         Wed,  7 Mar 90       Volume 90 : Issue  293
  3.  
  4. Today's Topics:
  5.                     MIDI Sequence Standard (Query)
  6. ----------------------------------------------------------------------
  7.  
  8. Date: 6 Mar 90 14:40:51 GMT
  9. From: att!dptg!lzsc!hcj@ucbvax.Berkeley.EDU  (HC Johnson)
  10. Subject: MIDI Sequence Standard (Query)
  11. Message-ID: <1361@lzsc.ATT.COM>
  12.  
  13. In article <4280010@hpgnd.HP.COM>, jmrosset@hpgnd.HP.COM (Jean-Michel ROSSET)
  14.  writes:
  15. >
  16. > I am also interested by this information and I could not reach Stephen
  17. > by e-mail. If anybody has this information electronically available, I
  18. > think it is interesting enough to post it.
  19. >
  20.  
  21. Howard C. Johnson
  22. ATT Bell Labs
  23. att!lzsc!hcj
  24. hcj@lzsc.att.com
  25.  
  26. #############
  27. # The following is the 'midifileformat' you requested from the midi-archive
  28. #############
  29.  
  30. Subject: Standard MIDI Files
  31.  
  32. From: czei@accelerator.eng.ohio-state.edu (Michael S. Czeiszperger)
  33.  
  34.  
  35. Standard MIDI Files 0.06        March 1, 1988
  36.  
  37.  
  38. 0  Introduction
  39.  
  40. This describes a proposed standard MIDI file format.  MIDI files contain
  41. one or more MIDI streams, with time information for each event.  Song,
  42. sequence, and track structures, tempo and time signature information,
  43. are all supported.  Track names and other descriptive information may be
  44. stored with the MIDI data.  This format supports multiple tracks and
  45. multiple sequences so that if the user of a program which supports
  46. multiple tracks intends to move a file to another one, this format can
  47. allow that to happen.
  48.  
  49. This spec defines the 8-bit binary data stream used in the file.  The
  50. data can be stored in a binary file, nibbleized, 7-bit-ized for
  51. efficient MIDI transmission, converted to Hex ASCII, or translated
  52. symbolically to a printable text file.  This spec addresses what's in
  53. the 8-bit stream.
  54.  
  55.  
  56.  
  57. We'd like to make MIDI Files 1.0 happen as soon as possible, so please
  58. respond soon with any comments or proposals you have about MIDI File
  59. transmission, the MIDI meta-event event or any other comments or
  60. questions you have about anything in this specification.
  61.  
  62.  
  63. Please direct comments to:
  64.  
  65. Dave Oppenheim
  66. Opcode Systems
  67. 1024 Hamilton Court
  68. Menlo Park, California 94025
  69. (415) 321-8977
  70.  
  71. 1  Sequences, Tracks, Chunks:  File Block Structure
  72.  
  73. Sequence files are made up of chunks.  Each chunk has a 4-character type
  74. and a 32-bit length, which is the number of bytes in the chunk.  On the
  75. Macintosh, data is passed either in the data fork of a file, or on the
  76. Clipboard.  (The file type on the Macintosh for a file in this format
  77. will be "Midi".)  On any other computer, the data is simply the contents
  78. of the file.  This structure allows future chunk types to be designed
  79. which may easily be ignored if encountered by a program written before
  80. the chunk type is introduced.   Your programs should expect alien chunks
  81. and treat them as if they weren't there.
  82.  
  83. This proposal defines two types of chunks:  a header chunk and a track
  84. chunk.  A header chunk provides a minimal amount of information
  85. pertaining to the entire MIDI file.  A track chunk contains a sequential
  86. stream of MIDI data which may contain information for up to 16 MIDI
  87. channels.  The concepts of multiple tracks, multiple MIDI outputs,
  88. patterns, sequences, and songs may all be implemented using several
  89. track chunks.
  90.  
  91. A MIDI file always starts with a header chunk, and is followed by one or
  92. more track chunks.
  93.  
  94. MThd  <length of header data>
  95. <header data>
  96. MTrk  <length of track data>
  97. <track data>
  98. MTrk  <length of track data>
  99. <track data>
  100.  ...
  101.  
  102. Track Data Format (MTrk chunk type)
  103.  
  104. The MTrk chunk type is where actual song data is stored.  It is simply a
  105. stream of MIDI events (and non-MIDI events), preceded by delta-time
  106. values.
  107.  
  108. Some numbers in MTrk chunks are represented in a form called a variable-
  109. length quantity. These numbers are represented 7 bits per byte, most
  110. significant bits first.  All bytes except the last have bit 7 set, and
  111. the last byte has bit 7 clear.  If the number is between 0 and 127,  it
  112. is thus represented exactly as one byte.
  113.  
  114. Here are some examples of numbers represented as variable-length
  115. quantities:
  116.  
  117.         Number (hex)    Representation (hex)
  118.         00000000        00
  119.         00000040        40
  120.         0000007F        7F
  121.         00000080        81 00
  122.         00002000        C0 00
  123.         00003FFF        FF 7F
  124.         00004000        81 80 00
  125.         00100000        C0 80 00
  126.         001FFFFF        FF FF 7F
  127.         00200000        81 80 80 00
  128.         08000000        C0 80 80 00
  129.         0FFFFFFF        FF FF FF 7F
  130.  
  131.  
  132. The largest number which is allowed is 0FFFFFFF so that the variable-
  133. length representation must fit in 32 bits in a routine to write
  134. variable-length numbers.  Theoretically, larger numbers are possible,
  135. but 2 x 108 96ths of a beat at a fast tempo of 500 beats per minute is
  136. four days, long enough for any delta-time!
  137.  
  138. Here is the syntax of an MTrk chunk:
  139.  
  140. <track data> = <MTrk event>+
  141.  
  142. <MTrk event> = <delta-time> <event>
  143.  
  144. <delta-time> is stored as a variable-length quantity.  It represents the
  145. amount of time before the following event.  If the first event in a
  146. track occurs at the very beginning of a track, or if two events occur
  147. simultaneously, a delta-time of zero is used.  Delta-times are always
  148. present.  (Not storing delta-times of 0 requires at least two bytes for
  149. any other value, and most delta-times aren't zero.)  Delta-time is in
  150. some fraction of a beat (or a second, for recording a track with SMPTE
  151. times), as specified in the header chunk.
  152.  
  153. <event> = <MIDI event> | <sysex event> | <meta-event>
  154.  
  155. <MIDI event> is any MIDI channel message.  Running status is used:
  156. status bytes may be omitted after the first byte.  The first event in a
  157. file must specify status.  Delta-time is not  considered an event
  158. itself:  it is an integral part of the specification.  Notice that
  159. running status occurs across delta-times.
  160.  
  161. <meta-event> specifies non-MIDI information useful to this format or to
  162. sequencers, with this syntax:
  163.  
  164.         FF <type> <length> <bytes>
  165.  
  166. All meta-events begin with FF, then have an event type byte (which is
  167. always less than 128), and then have the length of the data stored as a
  168. variable-length quantity, and then the data itself.  If there is no
  169. data, the length is 0.  As with sysex events, running status is not
  170. allowed.  As with chunks, future meta-events may be designed which may
  171. not be known to existing programs, so programs must properly ignore
  172. meta-events which they do not recognize, and indeed, should expect to
  173. see them.  New for 0.06:  programs must never ignore the length of a
  174. meta-event which they do recognize, and they shouldn't be surprised if
  175. it's bigger than they expected.  If so, they must ignore everything past
  176. what they know about.  However, they must not add anything of their own
  177. to the end of a meta-event.
  178.  
  179. <sysex event> is used to specify a MIDI system exclusive message, or as
  180. an "escape" to specify any arbitrary bytes to be transmitted.
  181. Unfortunately, some synthesizer manufacturers specify that their system
  182. exclusive messages are to be transmitted as little packets.  Each packet
  183. is only part of an entire syntactical system exclusive message, but the
  184. times they are transmitted at are important.  Examples of this are the
  185. bytes sent in a CZ patch dump, or the FB-01's "system exclusive mode" in
  186. which microtonal data can be transmitted.  To be able to handle
  187. situations like these, two forms of  <sysex event> are provided:
  188.  
  189.         F0 <length> <bytes to be transmitted after F0>
  190.         F7 <length> <all bytes to be transmitted>
  191.  
  192. In both cases, <length> is stored as a variable-length quantity.  It is
  193. equal to the number of bytes following it, not including itself or the
  194. message type (F0 or F7), but all the bytes which follow, including any
  195. F7 at the end which is intended to be transmitted.  The first form, with
  196. the F0 code, is used for syntactically complete system exclusive
  197. messages, or the first packet an a series Q that is, messages in which
  198. the F0 should be transmitted.  The second form is used for the remainder
  199. of the packets within a syntactic sysex message, which do not begin with
  200. F0.  Of course, the F7 is not considered part of the system exclusive
  201. message.  Of course, just as in MIDI, running status is not allowed, in
  202. this case because the length is stored as a variable-length quantity
  203. which may or may not start with bit 7 set.
  204.  
  205. (New to 0.06)  A syntactic system exclusive message must always end with
  206. an F7, even if the real-life device didn't send one, so that you know
  207. when you've reached the end of an entire sysex message without looking
  208. ahead to the next event in the MIDI file.  This principle is repeated
  209. and illustrated in the paragraphs below.
  210.  
  211. The vast majority of system exclusive messages will just use the F0
  212. format.  For instance, the transmitted message F0 43 12 00 07 F7 would
  213. be stored in a MIDI file as F0 05 43 12 00 07 F7.  As mentioned above,
  214. it is required to include the F7 at the end so that the reader of the
  215. MIDI file knows that it has read the entire message.
  216.  
  217. For special situations when a single system exclusive message is split
  218. up, with parts of it being transmitted at different times, such as in a
  219. Casio CZ patch transfer, or the FB-01's "system exclusive mode", the F7
  220. form of sysex event is used for each packet except the first.  None of
  221. the packets would end with an F7 except the last one, which must end
  222. with an F7.  There also must not be any transmittable MIDI events in-
  223. between the packets of a multi-packet system exclusive message.  Here is
  224. an example:  suppose the bytes F0 43 12 00 were to be sent, followed by
  225. a 200-tick delay, followed by the bytes  43 12 00 43 12 00, followed by
  226. a 100-tick delay, followed by the bytes  43 12 00 F7, this would be in
  227. the MIDI File:
  228.  
  229.         F0 03 43 12 00
  230.         81 48                                   200-tick delta-time
  231.         F7 06 43 12 00 43 12 00
  232.         64                                      100-tick delta-time
  233.         F7 04 43 12 00 F7
  234.  
  235. The F7 event may also be used as an "escape" to transmit any bytes
  236. whatsoever, including real-time bytes, song pointer, or MIDI Time Code,
  237. which are not permitted normally in this specification.  No effort
  238. should be made to interpret the bytes used in this way.  Since a system
  239. exclusive message is not being transmitted, it is not necessary or
  240. appropriate to end the F7 event with an F7 in this case.
  241.  
  242.  
  243. 2    Header Chunk
  244.  
  245. The header chunk at the beginning of the file specifies some basic
  246. information about the data in the file.  The data section contains three
  247. 16-bit words, stored high byte first (of course).  Here's the syntax of
  248. the complete chunk:
  249.  
  250.         <chunk type> <length> <format> <ntrks> <division>
  251.  
  252. As described above, <chunk type> is the four ASCII characters 'MThd';
  253. <length> is a 32-bit representation of the number 6 (high byte first).
  254. The first word, format, specifies the overall organization of the file.
  255. Only three values of format are specified:
  256.  
  257.         0       the file contains a single multi-channel track
  258.         1       the file contains one or more simultaneous tracks (or MIDI
  259. outputs) of a sequence
  260.         2       the file contains one or more sequentially independent
  261. single-track patterns
  262.  
  263. The next word, ntrks, is the number of track chunks in the file.  The
  264. third word, division,  is the division of a quarter-note represented by
  265. the delta-times in the file.  (If division is negative, it represents
  266. the division of a second represented by the delta-times in the file, so
  267. that the track can represent events occurring in actual time instead of
  268. metrical time.  It is represented in the following way:  the upper byte
  269. is one of the four values -24, -25, -29, or -30, corresponding to the
  270. four standard SMPTE and MIDI time code formats, and represents the
  271. number of frames per second.  The second byte (stored positive) is the
  272. resolution within a frame:  typical values may be 4 (MIDI time code
  273. resolution), 8, 10, 80 (bit resolution), or 100.  This system allows
  274. exact specification of time-code-based tracks, but also allows
  275. millisecond-based tracks by specifying 25 frames/sec and a resolution of
  276. 40 units per frame.)
  277.  
  278. Format 0, that is, one multi-channel track, is the most interchangeable
  279. representation of data.  One application of MIDI files is a simple
  280. single-track player in a program which needs to make synthesizers make
  281. sounds, but which is primarily concerned with something else such as
  282. mixers or sound effect boxes.  It is very desirable to be able to
  283. produce such a format, even if your program is track-based, in order to
  284. work with these simple programs.  On the other hand, perhaps someone
  285. will write a format conversion from format 1 to format 0 which might be
  286. so easy to use in some setting that it would save you the trouble of
  287. putting it into your program.
  288.  
  289. Programs which support several simultaneous tracks should be able to
  290. save and read data in format 1, a vertically one-dimensional form, that
  291. is, as a collection of tracks.  Programs which support several
  292. independent patterns should be able to save and read data in format 2, a
  293. horizontally one-dimensional form.  Providing these minimum capabilities
  294. will ensure maximum interchangeability.
  295.  
  296. MIDI files can express tempo and time signature, and they have been
  297. chosen to do so for transferring tempo maps from one device to another.
  298. For a format 0 file, the tempo will be scattered through the track and
  299. the tempo map reader should ignore the intervening events; for a format
  300. 1 file, the tempo map must (starting in 0.04) be stored as the first
  301. track.  It is polite to a tempo map reader to offer your user the
  302. ability to make a format 0 file with just the tempo, unless you can use
  303. format 1.
  304.  
  305. All MIDI files should specify tempo and time signature.  If they don't,
  306. the time signature is assumed to be 4/4, and the tempo 120 beats per
  307. minute.  In format 0, these meta-events should occur at least at the
  308. beginning of the single multi-channel track.  In format 1, these meta-
  309. events should be contained in the first track.  In format 2, each of the
  310. temporally independent patterns should contain at least initial time
  311. signature and tempo information.
  312.  
  313. We may decide to define other format IDs to support other structures.  A
  314. program reading an unfamiliar format ID should return an error to the
  315. user rather than trying to read further.
  316.  
  317. 3    Meta-Events
  318.  
  319. A few meta-events are defined herein.  It is not required for every
  320. program to support every meta-event.  Meta-events initially defined
  321. include:
  322.  
  323. FF 00 02 ssss   Sequence Number
  324. This optional event, which must occur at the beginning of a track,
  325. before any nonzero delta-times, and before any transmittable MIDI
  326. events, specifies the number of a sequence.  The number in this track
  327. corresponds to the sequence number in the new Cue message discussed at
  328. the summer 1987 MMA meeting.  In a format 2 MIDI file, it is used to
  329. identify each "pattern" so that a "song" sequence using the Cue message
  330. to refer to the patterns.  If the ID numbers are omitted, the sequences'
  331. locations in order in the file are used as defaults.  In a format 0 or 1
  332. MIDI file, which only contain one sequence, this number should be
  333. contained in the first (or only) track.  If transfer of several
  334. multitrack sequences is required, this must be done as a group of format
  335. 1 files, each with a different sequence number.
  336.  
  337. FF 01 len text  Text Event
  338. Any amount of text describing anything.  It is a good idea to put a text
  339. event right at the beginning of a track, with the name of the track, a
  340. description of its intended orchestration, and any other information
  341. which the user wants to put there.  Text events may also occur at other
  342. times in a track, to be used as lyrics, or descriptions of cue points.
  343. The text in this event should be printable ASCII characters for maximum
  344. interchange.  However, other character codes using the high-order bit
  345. may be used for interchange of files between different programs on the
  346. same computer which supports an extended character set.  Programs on a
  347. computer which does not support non-ASCII characters should ignore those
  348. characters.
  349.  
  350. (New for 0.06 ).  Meta event types 01 through 0F are reserved for
  351. various types of text events, each of which meets the specification of
  352. text events(above) but is used for a different purpose:
  353.  
  354. FF 02 len text  Copyright Notice
  355. Contains a copyright notice as printable ASCII text.  The notice should
  356. contain the characters (C), the year of the copyright, and the owner of
  357. the copyright.  If several pieces of music are in the same MIDI file,
  358. all of the copyright notices should be placed together in this event so
  359. that it will be at the beginning of the file.  This event should be the
  360. first event in the first track chunk, at time 0.
  361.  
  362.  
  363. FF 03 len text  Sequence/Track Name
  364. If in a format 0 track, or the first track in a format 1 file, the name
  365. of the sequence.  Otherwise, the name of the track.
  366.  
  367. FF 04 len text  Instrument Name
  368. A description of the type of instrumentation to be used in that track.
  369. May be used with the MIDI Prefix meta-event to specify which MIDI
  370. channel the description applies to, or the channel may be specified as
  371. text in the event itself.
  372.  
  373. FF 05 len text  Lyric
  374. A lyric to be sung.  Generally, each syllable will be a separate lyric
  375. event which begins at the event's time.
  376.  
  377. FF 06 len text  Marker
  378. Normally in a format 0 track, or the first track in a format 1 file.
  379. The name of that point in the sequence, such as a rehearsal letter or
  380. section name ("First Verse", etc.).
  381.  
  382.  
  383. FF 07 len text  Cue Point
  384. A description of something happening on a film or video screen or stage
  385. at that point in the musical score ("Car crashes into house", "curtain
  386. opens", "she slaps his face", etc.)
  387.  
  388. FF 2F 00        End of Track
  389. This event is not optional.  It is included so that an exact ending
  390. point may be specified for the track, so that it has an exact length,
  391. which is necessary for tracks which are looped or concatenated.
  392.  
  393. FF 51 03 tttttt         Set Tempo, in microseconds per MIDI quarter-note
  394. This event indicates a tempo change.  Another way of putting
  395. "microseconds per quarter-note" is "24ths of a microsecond per MIDI
  396. clock".  Representing tempos as time per beat instead of beat per time
  397. allows absolutely exact long-term synchronization with a time-based sync
  398. protocol such as SMPTE time code or MIDI time code.  This amount of
  399. accuracy provided by this tempo resolution allows a four-minute piece at
  400. 120 beats per minute to be accurate within 500 usec at the end of the
  401. piece.  Ideally, these events should only occur where MIDI clocks would
  402. be located Q this convention is intended to guarantee, or at least
  403. increase the likelihood, of compatibility with other synchronization
  404. devices so that a time signature/tempo map stored in this format may
  405. easily be transferred to another device.
  406.  
  407. FF 54 05 hr mn se fr ff SMPTE Offset  (New in 0.06 - SMPTE Format
  408. specification)
  409. This event, if present, designates the SMPTE time at which the track
  410. chunk is supposed to start.  It should be present at the beginning of
  411. the track, that is, before any nonzero delta-times, and before any
  412. transmittable MIDI events.  The hour must be encoded with the SMPTE
  413. format, just as it is in MIDI Time Code.  In a format 1 file, the SMPTE
  414. Offset must be stored with the tempo map, and has no meaning in any of
  415. the other tracks.  The ff field contains fractional frames, in 100ths of
  416. a frame, even in SMPTE-based tracks which specify a different frame
  417. subdivision for delta-times.
  418.  
  419. FF 58 04 nn dd cc bb    Time Signature
  420. The time signature is expressed as four numbers.  nn and dd represent
  421. the numerator and denominator of the time signature as it would be
  422. notated.  The denominator is a negative power of two:  2 represents a
  423. quarter-note, 3 represents an eighth-note, etc.  The cc parameter
  424. expresses the number of MIDI clocks in a metronome click.  The bb
  425. parameter expresses the number of notated 32nd-notes in a MIDI quarter-
  426. note (24 MIDI Clocks).  This was added because there are already
  427. multiple programs which allow the user to specify that what MIDI thinks
  428. of as a quarter-note (24 clocks) is to be notated as, or related to in
  429. terms of, something else.
  430.  
  431. Therefore, the complete event for 6/8 time, where the metronome clicks
  432. every three eighth-notes, but there are 24 clocks per quarter-note, 72
  433. to the bar, would be (in hex):
  434.  
  435.         FF 58 04 06 03 24 08
  436.  
  437. That is, 6/8 time (8 is 2 to the 3rd power, so this is 06 03), 32 MIDI
  438. clocks per dotted-quarter (24 hex!), and eight notated 32nd-notes per
  439. MIDI quarter note.
  440.  
  441. FF 59 02 sf mi  Key Signature
  442.         sf = -7:  7 flats
  443.         sf = -1:  1 flat
  444.         sf = 0:  key of C
  445.         sf = 1:  1 sharp
  446.         sf = 7: 7 sharps
  447.  
  448.         mi = 0:  major key
  449.         mi = 1:  minor key
  450.  
  451. FF 7F len data  Sequencer-Specific Meta-Event
  452.  
  453.         Special requirements for particular sequencers may use this
  454. event type:  the first byte or bytes of data is a manufacturer ID.
  455. However, as this is an interchange format, growth of the spec proper is
  456. preferred to use of this event type.  This type of event may be used by
  457. a sequencer which elects to use this as its only file format;
  458. sequencers with their established feature-specific formats should
  459. probably stick to the standard features when using this format.
  460.  
  461. 4   Program Fragments and Example MIDI Files
  462.  
  463. Here are some of the routines to read and write variable-length numbers
  464. in MIDI Files.  These routines are in C, and use getc and putc, which
  465. read and write single 8-bit characters from/to the files infile and
  466. outfile.
  467.  
  468. WriteVarLen (value)
  469. register long value;
  470. ?
  471.         register long buffer;
  472.  
  473.         buffer = value & 0x7f;
  474.         while ((value >>= 7) > 0)
  475.         ?
  476.                 buffer <<= 8;
  477.                 buffer |= 0x80;
  478.                 buffer += (value & 0x7f);
  479.         ?
  480.  
  481.         while (TRUE)
  482.         ?
  483.                 putc(buffer,outfile);
  484.                 if (buffer & 0x80)
  485.                         buffer >>= 8;
  486.                 else
  487.                         break;
  488.         ?
  489. ?
  490.  
  491. doubleword ReadVarLen ()
  492. ?
  493.         register doubleword value;
  494.         register byte c;
  495.  
  496.         if ((value = getc(infile)) & 0x80)
  497.         ?
  498.                 value &= 0x7f;
  499.                 do
  500.                 ?
  501.                         value = (value << 7) + ((c = getc(infile)) & 0x7f);
  502.                 ? while (c & 0x80);
  503.         ?
  504.         return (value);
  505. ?
  506.  
  507. As an example, MIDI Files for the following excerpt are shown below.
  508. First, a format 0 file is shown, with all information intermingled;
  509. then, a format 1 file is shown with all data separated into four tracks:
  510. one for tempo and time signature, and three for the notes.  A resolution
  511. of 96 "ticks" per quarter note is used.  A time signature of 4/4 and a
  512. tempo of 120, though implied, are explicitly stated.
  513.  
  514.  
  515.  
  516.  
  517. The contents of the MIDI stream represented by this example are broken
  518. down here:
  519.  
  520. Delta Time(decimal)  Event Code (hex)   Other Bytes (decimal)
  521.         Comment
  522.         0       FF 58   04 04 02 24 08  4 bytes: 4/4 time, 24 MIDI
  523. clocks/click,
  524.                                 8 32nd notes/24 MIDI clocks
  525.         0       FF 51   03 500000       3 bytes: 500,000 5sec per quarter-note
  526.         0       C0      5       Ch. 1, Program Change 5
  527.         0       C0      5       Ch. 1, Program Change 5
  528.         0       C1      46      Ch. 2, Program Change 46
  529.         0       C2      70      Ch. 3, Program Change 70
  530.         0       92      48  96  Ch. 3 Note On C2, forte
  531.         0       92      60  96  Ch. 3 Note On C3, forte
  532.         96      91      67  64  Ch. 2 Note On G3, mezzo-forte
  533.         96      90      76  32  Ch. 1 Note On E4, piano
  534.         192     82      48  64  Ch. 3 Note Off C2, standard
  535.         0       82      60  64  Ch. 3 Note Off C3, standard
  536.         0       81      67  64  Ch. 2 Note Off G3, standard
  537.         0       80      76  64  Ch. 1 Note Off E4, standard
  538.         0       FF 2F   00      Track End
  539.  
  540. The entire format 0 MIDI file contents in hex follow.  First, the header
  541. chunk:
  542.  
  543.                 4D 54 68 64     MThd
  544.                 00 00 00 06     chunk length
  545.                 00 00   format 0
  546.                 00 01   one track
  547.                 00 60   96 per quarter-note
  548.  
  549. Then, the track chunk.  Its header, followed by the events (notice that
  550. running status is used in places):
  551.  
  552.                 4D 54 72 6B     MTrk
  553.                 00 00 00 3B     chunk length (59)
  554.  
  555.         Delta-time      Event   Comments
  556.         00      FF 58 04 04 02 18 08    time signature
  557.         00      FF 51 03 07 A1 20       tempo
  558.         00      C0 05
  559.         00      C1 2E
  560.         00      C2 46
  561.         00      92 30 60
  562.         00      3C 60   running status
  563.         60      91 43 40
  564.         60      90 4C 20
  565.         81 40   82 30 40        two-byte delta-time
  566.         00      3C 40   running status
  567.         00      81 43 40
  568.         00      80 4C 40
  569.         00      FF 2F 00        end of track
  570.  
  571. A format 1 representation of the file is slightly different.  Its header
  572. chunk:
  573.  
  574.                 4D 54 68 64     MThd
  575.                 00 00 00 06     chunk length
  576.                 00 01   format 1
  577.                 00 04   four tracks
  578.                 00 60   96 per quarter-note
  579.  
  580. First, the track chunk for the time signature/tempo track.  Its header,
  581. followed by the events:
  582.  
  583.                 4D 54 72 6B     MTrk
  584.                 00 00 00 14     chunk length (20)
  585.  
  586.         Delta-time      Event   Comments
  587.         00      FF 58 04 04 02 18 08    time signature
  588.         00      FF 51 03 07 A1 20       tempo
  589.         83 00   FF 2F 00        end of track
  590.  
  591. Then, the track chunk for the first music track.  The MIDI convention
  592. for note on/off running status is used in this example:
  593.  
  594.                 4D 54 72 6B     MTrk
  595.                 00 00 00 10     chunk length (16)
  596.  
  597.         Delta-time      Event   Comments
  598.         00      C0 05
  599.         81 40   90 4C 20
  600.         81 40   4C 00   Running status: note on, vel = 0
  601.         00      FF 2F 00        end of track
  602.  
  603. Then, the track chunk for the second music track:
  604.  
  605.                 4D 54 72 6B     MTrk
  606.                 00 00 00 0F     chunk length (15)
  607.  
  608.         Delta-time      Event   Comments
  609.         00      C1 2E
  610.         60      91 43 40
  611.         82 20   43 00   running status
  612.         00      FF 2F 00        end of track
  613.  
  614. Then, the track chunk for the third music track:
  615.  
  616.                 4D 54 72 6B     MTrk
  617.                 00 00 00 15     chunk length (21)
  618.  
  619.         Delta-time      Event   Comments
  620.         00      C2 46
  621.         00      92 30 60
  622.         00      3C 60   running status
  623.         83 00   30 00   two-byte delta-time, running status
  624.         00      3C 00   running status
  625.         00      FF 2F 00        end of track
  626.  
  627. 5   MIDI Transmission of MIDI Files
  628.  
  629. Since it is inconvenient to exchange disks between different computers,
  630. and since many computers which will use this format will have a MIDI
  631. interface anyway, MIDI seems like a perfect way to send these files from
  632. one computer to another.  And, while we're going through all the trouble
  633. to make a way of sending MIDI Files, it would be nice if they could send
  634. any files (like sampled sound files, text files, etc.)
  635.  
  636. Goals
  637. The transmission protocol for MIDI files should be reasonably efficient,
  638. should support fast transmission for computers which are capable of it,
  639. and slower transmission for less powerful ones.  It should not be
  640. impossible to convert a MIDI File to or from an arbitrary internal
  641. representation on the fly as it is transmitted, but, as long as it is
  642. not too difficult, it is very desirable to use a generic method so that
  643. any file type could be accommodated.
  644.  
  645. To make the protocol efficient, the MIDI transmission of these files
  646. will take groups of seven 8-bit bytes and transmit them as eight 7-bit
  647. MIDI data bytes.  This is certainly in the spirit of the rest of this
  648. format (keep it small, because it's not that hard to do).  To
  649. accommodate a wide range of transmission speeds, files will be
  650. transmitted in packets with acknowledge -- this allows data to be stored
  651. to disk as it is received.  If the sender does not receive a response
  652. from a reader in a certain amount of time, it can assume an open-loop
  653. situation, and then just continue.
  654.  
  655. The last edition of MIDI Files contained a specialized protocol for
  656. sending just MIDI Files.  To meet a deadline, unfortunately I don't have
  657. time right now to propose a new generalized protocol.  This will be done
  658. within the next couple of months.  I would welcome any proposals anyone
  659. else has, and would direct your attention to the proposal from Ralph
  660. Muha of Kurzweil, available in a recent MMA bulletin, and also directly
  661. from him.
  662.  
  663. ------------------------------
  664.  
  665. End of INFO-ATARI16 Digest V90 Issue #293
  666. *****************************************
  667.